package tp.pr5.gui;

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;

import tp.pr5.PlaceInfo;

public class LogView extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JTextArea logTA;
	private JLabel infoLabel;
	
	/**
	 * Default constructor
	 */
	public LogView (){		
		this.setBorder(new TitledBorder("Log"));
		this.setLayout(new BorderLayout());		
		build();
	}
	/**
	 * Builds the interface
	 */
	private void build(){
		logTA = new JTextArea();
		logTA.setRows(10);
		
		JPanel infoPanel = new JPanel();
		infoLabel = new JLabel();
		infoPanel.add(infoLabel);		
		this.add(new JScrollPane(logTA),BorderLayout.CENTER);
		this.add(infoPanel, BorderLayout.SOUTH);
		
	}
	/**
	 * Refreshes the status log textarea
	 */
	public void refresh(PlaceInfo place){
		logTA.setText(place.toString());
	}
	/**
	 * 
	 */
	public JTextArea getTextArea(){
		return this.logTA;
	}
	/**
	 * Sets the infoLabel text
	 */
	public void setInfoText(String text){
		this.infoLabel.setText(text);
	}
}
